package java_test;

import java.util.HashSet;
import java.util.Set;

public class ArrayUnion {
    public static void main(String[] args) {
        String[] ary1 = {"1", "2", "3"};
        String[] ary2 = {"4", "5", "6"};
        String[] result_union = union(ary1, ary2);
        System.out.println("并集的结果如下：");

        for (String str : result_union) {
            System.out.println(str);
        }
    }

    private static String[] union(String[] ary1, String[] ary2) {
        Set<String> set = new HashSet<String>();
        for (String str : ary1) {
            set.add(str);
        }
        for (String str : ary2) {
            set.add(str);
        }
        String[] result = {};
        return set.toArray(result);
    }

//    public static void union(String[] arys1, String[] arys2) {
//
//    }
}
